You can write some text appearing in both files using the standard markup language.

Use the r chunk to display some code in both files.

head(cars)
##   speed dist
## 1     4    2
## 2     4   10
## 3     7    4
## 4     7   22
## 5     8   16
## 6     9   10

Use the r chunk with solution = TRUE to display and evaluate the chunk only in the solution file.

You can also add some markdown formatted text with the asis engine together with solution = TRUE

Use the knit dropdown menu on the knit button to generate the desired output:

Tip

You can also include custom boxes to highlight some content. Read the article to learn more about how to customize the appearance.

1

Load the tidyr library
Use library().